|
1
|
|
|
// Type definitions for wavefile-parser 1.0 |
|
2
|
|
|
// Project: https://github.com/rochars/wavefile-parser |
|
3
|
|
|
// Definitions by: Rafael da Silva Rocha <https://github.com/rochars> |
|
4
|
|
|
// Definitions: https://github.com/rochars/wavefile-parser |
|
5
|
|
|
|
|
6
|
|
|
export = wavefileParser; |
|
7
|
|
|
|
|
8
|
|
|
declare module wavefileParser { |
|
9
|
|
|
|
|
10
|
|
|
class WaveFileParser { |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @param {?Uint8Array=} bytes A wave file buffer. |
|
14
|
|
|
* @throws {Error} If no 'RIFF' chunk is found. |
|
15
|
|
|
* @throws {Error} If no 'fmt ' chunk is found. |
|
16
|
|
|
* @throws {Error} If no 'data' chunk is found. |
|
17
|
|
|
*/ |
|
18
|
|
|
constructor(bytes?: Uint8Array); |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* The container identifier. |
|
22
|
|
|
* 'RIFF', 'RIFX' and 'RF64' are supported. |
|
23
|
|
|
* @type {string} |
|
24
|
|
|
*/ |
|
25
|
|
|
container: string; |
|
26
|
|
|
/** |
|
27
|
|
|
* @type {number} |
|
28
|
|
|
*/ |
|
29
|
|
|
chunkSize: number; |
|
30
|
|
|
/** |
|
31
|
|
|
* The format. |
|
32
|
|
|
* Always 'WAVE'. |
|
33
|
|
|
* @type {string} |
|
34
|
|
|
*/ |
|
35
|
|
|
format: string; |
|
36
|
|
|
/** |
|
37
|
|
|
* The data of the 'fmt' chunk. |
|
38
|
|
|
* @type {!Object<string, *>} |
|
39
|
|
|
*/ |
|
40
|
|
|
fmt: object; |
|
41
|
|
|
/** |
|
42
|
|
|
* The data of the 'fact' chunk. |
|
43
|
|
|
* @type {!Object<string, *>} |
|
44
|
|
|
*/ |
|
45
|
|
|
fact: object; |
|
46
|
|
|
/** |
|
47
|
|
|
* The data of the 'cue ' chunk. |
|
48
|
|
|
* @type {!Object<string, *>} |
|
49
|
|
|
*/ |
|
50
|
|
|
cue: object; |
|
51
|
|
|
/** |
|
52
|
|
|
* The data of the 'smpl' chunk. |
|
53
|
|
|
* @type {!Object<string, *>} |
|
54
|
|
|
*/ |
|
55
|
|
|
smpl: object; |
|
56
|
|
|
/** |
|
57
|
|
|
* The data of the 'bext' chunk. |
|
58
|
|
|
* @type {!Object<string, *>} |
|
59
|
|
|
*/ |
|
60
|
|
|
bext: object; |
|
61
|
|
|
/** |
|
62
|
|
|
* The data of the 'ds64' chunk. |
|
63
|
|
|
* Used only with RF64 files. |
|
64
|
|
|
* @type {!Object<string, *>} |
|
65
|
|
|
*/ |
|
66
|
|
|
ds64: object; |
|
67
|
|
|
/** |
|
68
|
|
|
* The data of the 'data' chunk. |
|
69
|
|
|
* @type {!Object<string, *>} |
|
70
|
|
|
*/ |
|
71
|
|
|
data: object; |
|
72
|
|
|
/** |
|
73
|
|
|
* The data of the 'LIST' chunks. |
|
74
|
|
|
* Each item in this list look like this: |
|
75
|
|
|
* { |
|
76
|
|
|
* chunkId: '', |
|
77
|
|
|
* chunkSize: 0, |
|
78
|
|
|
* format: '', |
|
79
|
|
|
* subChunks: [] |
|
80
|
|
|
* } |
|
81
|
|
|
* @type {!Array<!Object>} |
|
82
|
|
|
*/ |
|
83
|
|
|
LIST: object[]; |
|
84
|
|
|
/** |
|
85
|
|
|
* The data of the 'junk' chunk. |
|
86
|
|
|
* @type {!Object<string, *>} |
|
87
|
|
|
*/ |
|
88
|
|
|
junk: object; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Set up the WaveFileReader object from a byte buffer. |
|
92
|
|
|
* @param {!Uint8Array} bytes The buffer. |
|
93
|
|
|
* @param {boolean=} samples True if the samples should be loaded. |
|
94
|
|
|
* @throws {Error} If container is not RIFF, RIFX or RF64. |
|
95
|
|
|
* @throws {Error} If no 'fmt ' chunk is found. |
|
96
|
|
|
* @throws {Error} If no 'data' chunk is found. |
|
97
|
|
|
*/ |
|
98
|
|
|
fromBuffer(bytes: Uint8Array, samples?:boolean): void; |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Return a byte buffer representig the WaveFileParser object as a .wav file. |
|
102
|
|
|
* The return value of this method can be written straight to disk. |
|
103
|
|
|
* @return {!Uint8Array} A wav file. |
|
104
|
|
|
*/ |
|
105
|
|
|
toBuffer(): Uint8Array; |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|